import datetime
import random

from common.mysqlUtil import  exc_sql2
from common.YmlUtil import YmlUtil
from RootPath import RootPath
import os
path = os.path.join(RootPath.getRootPath(), "Application.yml")
MySQLconf = YmlUtil().readYml(path,"mysql_test_243")

def device_pump_runpower():
        print("=========ss====device_pump_runpower========")
        # INSERT INTO `waterdb_ii`.`device_pump_runpower`(`id_device`, `date_time`, `real_power`, `plan_power`) VALUES ('9', '2020-12-03 18:58:25', 30.00, 29.00);
        sql1="INSERT INTO `waterdb_ii`.`device_pump_runpower`(`id_device`, `date_time`, `real_power`, `plan_power`) VALUES ('9', '"
        dateTime = ( datetime.datetime.now()).strftime("%Y-%m-%d %H:%M:%S")
        value1=str(random.randint(30,40))
        value2=str(random.randint(30,40))
        value3=");"
        sql = sql1+dateTime+"',"+value1+","+value2+value3
        print(sql)
        exc_sql2(sql,MySQLconf)

# device_pump_runpower()